#pragma once

#include "src/base/Timestamp_v2.h" // Using your Timestamp replacement

#include <map> // Will be removed if ChannelMap is removed from base
#include <vector>

namespace sola // Or your chosen namespace
{
namespace net {

class Channel;   // Forward declaration
class EventLoop; // Forward declaration

class Poller // noncopyable can be omitted if no data members and virtual dtor is present
{
public:
    using ChannelList = std::vector<Channel*>; // Type alias for active channels

    explicit Poller(EventLoop* loop)
        : ownerLoop_(loop) {}    // Constructor can still exist to store ownerLoop_
    virtual ~Poller() = default; // Important: virtual destructor for base class

    /// Polls the I/O events.
    /// Must be called in the loop thread.
    virtual sola::Timestamp poll(int timeoutMs, ChannelList* activeChannels) = 0;

    /// Changes the interested I/O events.
    /// Must be called in the loop thread.
    virtual void updateChannel(Channel* channel) = 0;

    /// Remove the channel, when it destructs.
    /// Must be called in the loop thread.
    virtual void removeChannel(Channel* channel) = 0;

    /// Checks if this poller has the given channel.
    /// Must be called in the loop thread.
    virtual bool hasChannel(Channel* channel) const = 0;

    // Static factory method to create the default (EPoll) poller.
    // This can replace DefaultPoller.cc
    // Alternatively, EventLoop can directly create an EPollPoller instance.
    static Poller* newDefaultPoller(EventLoop* loop); // Implementation will be in a .cc or inline if simple

    void assertInLoopThread() const; // Implementation can be in Poller.cc or inline if EventLoop.h is included

protected:
    // No data members in a pure interface class.
    // Derived classes (like EPollPoller) will manage their own ChannelMap.
    // typedef std::map<int, Channel*> ChannelMap;
    // ChannelMap channels_;
    EventLoop* ownerLoop_; // Keep ownerLoop_ as it's common for all pollers to know their loop

private:
    // No private members needed for a pure interface typically,
    // but ownerLoop_ is a common protected/private member for convenience.
    // EventLoop* ownerLoop_; // Moved to protected or keep private if only used by constructor
};

} // namespace net
} // namespace sola
